package com.lightsaber.trade.core.dao.account;

import java.util.List;

import org.springframework.stereotype.Component;
import org.springside.modules.orm.Page;

import com.lightsaber.trade.core.dao.BaseDao;
import com.lightsaber.trade.core.entity.account.User;
import com.lightsaber.trade.core.entity.account.UserType;

/**
 * 用户对象的泛型DAO类.
 * 
 * @author LiuJian
 */
@Component
public class UserDao extends BaseDao<User, String> {

    public List<User> findByUserType(UserType userType) {
        eq("userType", userType);
        return list();

    }

    public Page<User> findPageByUserType(User user, UserType userType, Page<User> page) {
        if (user != null) {
            like("name", user.getName());
        }

        eq("userType", userType);

        return findPage(page);

    }

}
